<?php
/**
 * The Template for displaying product archives, including the main shop page which is a post type archive.
 *
 * Override this template by copying it to yourtheme/woocommerce/archive-product.php
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     2.0.0
 */

/* Note: This file has been altered by Laborator */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

get_header( 'shop' ); ?>

	<?php
		/**
		 * woocommerce_before_main_content hook
		 *
		 * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
		 * @hooked woocommerce_breadcrumb - 20
		 */
		do_action( 'woocommerce_before_main_content' );
	?>

		<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>

			<?php get_template_part('tpls/woocommerce-heading-title'); ?>

		<?php endif; ?>

		<?php do_action( 'woocommerce_archive_description' ); ?>

		<div class="row">
		<?php if ( have_posts() ) : ?>

			<?php
				/**
				 * woocommerce_before_shop_loop hook
				 *
				 * @hooked woocommerce_result_count - 20
				 * @hooked woocommerce_catalog_ordering - 30
				 */
				do_action( 'woocommerce_before_shop_loop' );
			?>

			<?php woocommerce_product_loop_start(); ?>

				<?php $categories = woocommerce_product_subcategories(); ?>

				<?php if($categories): global $woocommerce_loop; $woocommerce_loop['loop'] = 0; ?>
				<div class="category-separator"></div>
				<?php endif; ?>


				<?php while ( have_posts() ) : the_post(); ?>
					
					<?php global $product; $post; ?>
					
					<?php wc_get_template_part( 'content', 'product' ); ?>

				<?php endwhile; // end of the loop. ?>

			<?php woocommerce_product_loop_end(); ?>

			<?php
				/**
				 * woocommerce_after_shop_loop hook
				 *
				 * @hooked woocommerce_pagination - 10
				 */
				do_action( 'woocommerce_after_shop_loop' );
			?>

		<?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>222
		
			<?php wc_get_template( 'loop/no-products-found.php' ); ?>

		<?php endif; ?>
		<?php
			/**
			 * woocommerce_sidebar hook
			 *
			 * @hooked woocommerce_get_sidebar - 10
			 */
			do_action( 'woocommerce_sidebar' );

		?>


		
			<div class="col-md-3 col-sm-4">
				<div class="sidebar-yh">
					<h3 class="sidebar-yh-title">最新推荐</h3>
<?php 
    $latest_cat_post = new WP_Query( array('category_name' => 'tuijian'));
    if( $latest_cat_post->have_posts() ) : while( $latest_cat_post->have_posts() ) : $latest_cat_post->the_post();  ?>
        <?php if (has_post_thumbnail( $post->ID ) ): ?>
        <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
					<div class="sidebar-yh-txt">
						<a href="<?php the_permalink(); ?>"><img src="<?php echo $image[0]; ?>" alt=""><?php the_title_attribute(); ?></a>
					</div>
	<?php endif; ?>
    <?php endwhile; endif; ?>

				</div>
			</div>



		</div>

	<?php
		/**
		 * woocommerce_after_main_content hook
		 *
		 * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
		 */
		do_action( 'woocommerce_after_main_content' );
	?>
<div class="products-container col-md-9 col-sm-8">
<hr>
<h2>作者&老师</h2>
<div class="row tea-row">
	<?php 
    $latest_cat_post = new WP_Query( array('category_name' => 'teacher'));
    if( $latest_cat_post->have_posts() ) : while( $latest_cat_post->have_posts() ) : $latest_cat_post->the_post();  ?>
        <?php if (has_post_thumbnail( $post->ID ) ): ?>
        <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>

	<div class="col-xs-4 col-sm-3 th">
		<a href="<?php the_permalink(); ?>">
			<div class="tea">
				<div class="tea-top">
					<img src="<?php echo $image[0]; ?>" alt="">
				</div>
				<div class="tea-title">
					<h4><?php the_title_attribute(); ?></h4>
				</div>
			</div>
		</a>	
	</div>

	<?php endif; ?>
        <?php endwhile; endif; ?>
</div>
</div>
<?php get_footer( 'shop' ); ?>